<?php
include_once("include/include.php.inc");

html_header("Support");

list($status, $user) = auth_get_status();
echo "<div class='box'>\n"; 
echo " <div class='boxtop'><div></div></div>\n"; 
echo "  <div class='boxcontent'>\n"; 
if($status == AUTH_LOGGED){

if(license_has($user, "support")){

$username=$user['username'];
//echo $username;
/*   $backlink=getenv('HTTP_REFERER');*/

   $result = mysql_query( "SELECT tic_no, tic_user, tic_ip, DATE_FORMAT(tic_date,'%d/%m/%y') AS mtic_date, DATE_FORMAT(tic_time,'%T') AS mtic_time, tic_problem, tic_status FROM chd_tickets WHERE tic_status='O' AND tic_sup_name='$username'")
           or die("SELECT Error: ".mysql_error());

           $num_rows = mysql_num_rows($result);

           print "<TABLE width=\"100%\" bgcolor=\"#336699\" BORDER=\"0\" bordercolor=\"#FFFFFF\"><tr>";
           print "<th width=\"11%\" scope=\"col\"><span class=\"style6\">Ticket#</span></th>";
		   print "<th width=\"18%\" scope=\"col\"><span class=\"style6\">User</span></th>";
		   print "<th width=\"10%\" scope=\"col\"><span class=\"style6\">Date</span></th>";
		   print "<th width=\"10%\" scope=\"col\"><span class=\"style6\">IP</span></th>";
		   print "<th width=\"44%\" scope=\"col\"><span class=\"style6\">Problem</span></th>";
		   print "<th width=\"44%\" scope=\"col\"><span class=\"style6\">Status</span></th></tr>";

           while ($row = mysql_fetch_assoc($result)){
                 extract($row);
	         	 print "<tr><td bgcolor=\"#FFFFFF\"><span >$tic_no</span></th>";
                 print "<td bgcolor=\"#FFFFFF\" scope=\"col\"><div align=\"left\"><span class=\"style8\">$tic_user</span></div></td>";
                 print "<td bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\">$mtic_date-$mtic_time</span></td>";
                 print "<td bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\">$tic_ip</span></th>";
                 print "<td bgcolor=\"#FFFFFF\" scope=\"col\"><div align=\"left\"><span class=\"style8\">$tic_problem</span></div></td>";
                 /*print "<td><a href=\"edit_ticket.php?cmd=edit&tic_no=$tic_no\"><IMG src=\"../images/edit.gif\"></a></td>";*/
                 //print "<th bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\"><a href=\"asg_ticket.php?cmd=asg&tic_no=$tic_no\"><IMG src=\"../images/assign.gif\"></a></span></th>
				 print "<td bgcolor=\"#FFFFFF\" scope=\"col\"><div align=\"left\"><span class=\"style8\">";
				 if($tic_status=="C") 
					echo "closed"; 
				 else 
					echo "open"; 
				 echo "</span></div></th></tr>";
				 
				 
                 }
                 print "</table>\n";
                 print "<br>";print "<br>";
				 
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n";
echo "<br>";
echo "<div class='box'>\n"; 
echo " <div class='boxtop'><div></div></div>\n"; 
echo "  <div class='boxcontent'>\n"; 

				?>

<p align="left"><h3>Close Ticket by</h3></p>

<form action="close_tic.php" method="post" >
  <p>
    Ticket # : <input type="text" size="6" name="tic_no">
    <input type="submit" name="submit" value=" Submit ">
</p>
</form>
<?php 
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n";



}
else{
echo "<h2><center>You do not have the required permissions\n</center></h2>";
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n";

}}
else{

echo "<center><h2>You must log in First</h2></center>";
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n";
}
html_footer();
?>
